<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" errorPage="/error.jsp" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%>
<%
String menuItemActionName = "";
String parentMenuItemActionName = "";
if (null != UserUtil.getUser() && null != UserUtil.getCurrentMenuItem())
{
	MenuItem parent = UserUtil.getCurrentMenuItem().getParentMenuItem();
	if (null != parent)
		parentMenuItemActionName = parent.getActionName();
	menuItemActionName =UserUtil.getCurrentMenuItem().getActionName();
}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.stms.util.UserUtil"%>
<%@page import="com.feib.stms.model.MenuItem"%>
<%@page import="com.feib.stms.util.SpringContextUtil"%>
<%@page import="com.feib.stms.security.web.authentication.StmsDelegatingAuthenticationEntryPoint"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.Iterator"%>
<%@page import="org.springframework.security.web.util.RequestMatcher"%>
<%@page import="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/includes/meta.jsp"%>
	<title>遠銀網銀股票交割款扣撥系統 || <%=menuItemActionName%> <decorator:title /></title>
	<link rel="stylesheet" type="text/css" media="all" href="<c:url value='/styles/default/mainstyle.css'/>" />
	<link rel="stylesheet" type="text/css" media="all" href="<c:url value='/styles/default/jquery-ui-1.8.20.custom.css'/>" />
		
	<script type="text/javascript" src="<c:url value='/scripts/jquery/jquery-1.7.2.min.js'/>"></script>	
    <script type="text/javascript" src="<c:url value='/scripts/jquery/jquery.bgiframe-2.1.2.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/scripts/jquery/jquery-ui-1.8.20.custom.min.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/scripts/jquery/jquery.ui.datepicker-zh-TW.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/scripts/stms.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/scripts/loadingScreen.js'/>"></script>
	
	
	<script type="text/javascript">
	<!--
	$(document).ready(function() {
		    
    	$('.ui-state-default').hover(
			function(){ $(this).addClass('ui-state-hover'); }, 
			function(){ $(this).removeClass('ui-state-hover'); }
		);

		$('.ui-state-default').click(function(){
			$(this).toggleClass('ui-state-active');
		});      
    });
	
	<%
	if (null != UserUtil.getUser()){
	%>
	var sessionTimeout = <%= request.getSession().getMaxInactiveInterval() %>;
	// 將相關資料如此宣告以減少 memory leak
	var tConfig = {
       // 彈出即將登出提示的 timer   
       remindTimer:null,
       // 幾秒之後未動作即登出(這是定義值，不因倒數而遞減) , eg: 10*60 
       timeoutTime: sessionTimeout,
       // 開始提示之後幾秒後登出(這是定義值，不因倒數而遞減) 
       countingTime:60,
       // 幾秒之後顯示即將登出提示 (remindTime = timeoutTime - countingTime)
       remindTime:null
    };

    
    /*
     * 執行強制登出
     */
    function doForceLogout() 
    {
        window.onbeforeunload = null;
        window.location = '<c:url value='stms_security_logout'/>';
    }
    
    /*
     * 開始TimeOut倒數
     */
    function startPageTimeOutCounting() 
    {
        if(tConfig.remindTimer) clearTimeout(tConfig.remindTimer);
        tConfig.remindTime = tConfig.timeoutTime - tConfig.countingTime;
        tConfig.remindTimer = setTimeout("finalCounting()",tConfig.remindTime*1000);
    }               
    
    /*
     * 重新倒數
     */
    var resumeTimeout = function(win) 
    {
        if(tConfig.remindTimer) clearTimeout(tConfig.remindTimer);
        startPageTimeOutCounting();
        return true;
    };                  
    
    /*
     * 重新設定 Timeout時間為多少秒
     */
    function resetPageTimeout(iTimeoutTime) 
    {
        if( iTimeoutTime ) 
        {
            tConfig.timeoutTime = iTimeoutTime;
            startPageTimeOutCounting();
        }
    }
    
    /*
     * 觸發"即將登出提示"
     */
    function finalCounting() 
    {
        alert('Session Time out. 請重新登入系統！');
        doForceLogout();
    }
    
    resetPageTimeout(sessionTimeout);
    
	<%
	}
	//end by jimmyliu on 20120220
	%>
	
	
	//-->
	</script>
	
	<decorator:head />
</head>
<body <decorator:getProperty property="body.id" writeEntireProperty="true"/> <decorator:getProperty property="body.class" writeEntireProperty="true"/>>
<div id="wrapper">
	<div id="header">
		<div id="linkbar">
			<img src="<c:url value='/styles/default/image/home.png'/>" /><a href="<c:url value='/index.jsp'/>">系統首頁</a><br /> 
			<img src="<c:url value='/styles/default/image/circle.png'/>" /><a href="http://www.feib.com.tw/" target="_blank">遠東商銀</a><br />
			<img src="<c:url value='/styles/default/image/snow.png'/>" /><a href="mailto:b2bcsr@feib.com.tw">與我連絡</a>
		</div>
	</div><!-- end of #header -->
	
	<div id="marquee">
		<div><img src="<c:url value='/styles/default/image/marquee-left.jpg'/>" style="float:left;" />
		<%if (null != UserUtil.getUser()){
			out.print("您好,&nbsp; " + UserUtil.getUser().getUserName()+"&nbsp;!&nbsp;&nbsp; ");
			
		%><a href="<c:url value='/stms_security_logout'/>">登出</a>
		<%} else {%>
		<% 
			String loginUrl = "/login.jsp";
			StmsDelegatingAuthenticationEntryPoint entrys = (StmsDelegatingAuthenticationEntryPoint)SpringContextUtil.getBean("stmsAuthenticationEntryPoint");
			if (null != entrys)
			{
				Map entryPoints = entrys.getEntryPoints();
				Set keys = entryPoints.keySet();
				for (Iterator i = keys.iterator(); i.hasNext(); )
				{
					RequestMatcher requestMatcher = (RequestMatcher) i.next();
					if (requestMatcher.matches(request))
					{
						loginUrl = ((LoginUrlAuthenticationEntryPoint)entryPoints.get(requestMatcher)).getLoginFormUrl();
						break;
					} 
				}
			}
			pageContext.setAttribute("loginUrl", loginUrl);
		%>
		<a href="<c:url value='${loginUrl}'/>">登入</a>
		<%}%><img src="<c:url value='/styles/default/image/marquee-right.jpg'/>" />
		</div>
	</div><!-- end of #marquee -->
	
	<div id="container">
		<div id="sidebar">			
			<div id="menutree">
			<jsp:include page="/includes/menubar.jsp"/>
			</div><!-- end of #menutree -->
			
		</div><!-- end of #sidebar -->
			
		<div id="mainForm">
			<div id="location">
			<%if (null != UserUtil.getUser() && null != UserUtil.getCurrentMenuItem()){
				out.print(parentMenuItemActionName + "&nbsp;/&nbsp;");
				out.print(menuItemActionName);					
			} else out.println("&nbsp;");%>
			</div>
			<decorator:body/>
			
			<!-- Message -->
			<div id="messageDiv" style="display: none;"></div>
			
		</div><!-- end of #mainForm -->
		
	</div><!-- end of #container -->
	
	<div id="footer">
    	遠東國際商業銀行 版權所有 © 2012 Far Eastern International Bank. All Rights Reserved.
    </div>
	
</div><!-- end of #wrapper -->

<div id="loadingScreen"></div>
	
	
</body>
</html>
